import 'package:flutter/material.dart';
import 'package:flutter_app/components/msgList.dart';
import 'package:flutter_app/mock/jsonSelf.dart';
import './components/mineMsgCom.dart';

class MinePage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _mineState();
  }

}
class _mineState extends State{
  GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      backgroundColor:Color.fromRGBO(248, 248, 248,1) ,
      body: CustomScrollView(
        slivers: _sliverBuilder(),
    )
    );
  }

  List<Widget> _sliverBuilder() {
    List cardList = JsonSelf.cardList;
    return <Widget>[
      SliverAppBar(
        floating: true,
//        snap: true,
        pinned: true,
//        primary: false,
        expandedHeight: 300.0,
        backgroundColor: Colors.white,
        title:Text('原住居民'),
        flexibleSpace: Row(
          children: <Widget>[
            Expanded(
              child: Image.network('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576585329639&di=76a169a8c0d3290b58ec1f6f5e40ae0e&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201301%2F17%2F20130117202017_iuiz2.jpeg', fit: BoxFit.cover),
            )
          ],
        ),
        bottom: PreferredSize(
          preferredSize: Size.fromHeight(160),
          child:  MineMsgCom(),
        ),
      ),
      SliverList(
        delegate: SliverChildBuilderDelegate(
          (context,index){
            return Container(
                margin: EdgeInsetsDirectional.fromSTEB(0,10,0,0),
                padding: EdgeInsetsDirectional.fromSTEB(20,10,20,10),
              color: Colors.white,
              child: MsgList(cardList[index]['title'],cardList[index]['src'],cardList[index]['name'],cardList[index]['taglist'],cardList[index]['content'],cardList[index]['isImg'],cardList[index]['cImg'])
            );
          },
          childCount: cardList.length,
        ),
      )

    ];
  }

}